package com.heima.article.listener;

import com.heima.article.service.AddCommentService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class AddCommentListener {

    @Autowired
    private AddCommentService addCommentService;

    @KafkaListener(topics = "comment")
    public void addCommemt(String message){
        if(StringUtils.isNotBlank(message)){
            addCommentService.add(message);
        }
    }
}
